import request from "@/utils/request";

const BASE_URL = "/vehicles";

const VehicleAPI = {
  getInfo(id: string) {
    return request<any, any>({
      url: `${BASE_URL}/${id}`,
      method: "get",
    });
  },

  /** 获取角色分页数据 */
  getPage(queryParams?: any) {
    return request<any, PageResult<any[]>>({
      url: `${BASE_URL}`,
      method: "get",
      params: queryParams,
    });
  },
  /** 获取角色下拉数据源 */
  getOptions() {
    return request<any, OptionType[]>({ url: `${BASE_URL}/options`, method: "get" });
  },
  /** 获取角色的菜单ID集合 */
  getRoleMenuIds(roleId: string) {
    return request<any, string[]>({ url: `${BASE_URL}/${roleId}/menuIds`, method: "get" });
  },
  /** 分配菜单权限 */
  updateRoleMenus(roleId: string, data: number[]) {
    return request({ url: `${BASE_URL}/${roleId}/menus`, method: "put", data });
  },
  /** 获取角色表单数据 */
  getFormData(id: string) {
    return request<any, any>({ url: `${BASE_URL}/${id}/form`, method: "get" });
  },
  /** 新增角色 */
  create(data: any) {
    return request({ url: `${BASE_URL}`, method: "post", data });
  },
  /** 更新角色 */
  update(id: string, data: any) {
    return request({ url: `${BASE_URL}/${id}`, method: "put", data });
  },
  /** 批量删除角色，多个以英文逗号(,)分割 */
  deleteByIds(ids: string) {
    return request({ url: `${BASE_URL}/${ids}`, method: "delete" });
  },
};

export default VehicleAPI;
